package com.qh.yyxt.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.qh.yyxt.entity.DelayThing;
import com.qh.yyxt.entity.Flag;
import com.qh.yyxt.entity.GetAndReturn;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class FlagDTO
{
    private DelayThing delayThing;
    @JsonProperty("fid")
    private Integer fid;
    //private Integer uid;
    @JsonProperty("things")
    private String things;
    @JsonProperty("mes")
    private String mes;
    @JsonProperty("applicant")
    private String applicant;
    @JsonProperty("college")
    private String college;
    @JsonProperty("tel")
    private String tel;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date applyTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date startTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date endTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date passTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date returnTime;
    @JsonProperty("approver")
    private String approver;
    //它的state取决去
    @JsonProperty("state")
    private String state;

    @JsonProperty("examineState")//借用状态
    private String examineState;

    @JsonProperty("activityname")//活动名称
    private String activityname;
    @JsonProperty("damageis")
    private Boolean damageis;//是否损坏
    @JsonProperty("borrowplace")//借用地点
    private String borrowplace;
    @JsonProperty("damage")//损坏情况
    private String damage;
    @JsonProperty("needReturnSigns")
    private String needReturnSigns;//需要归还物品编号
    @JsonProperty("allReturnSigns")
    private String allReturnSigns;//借用的总物品编号
    @JsonProperty("alreadyReturnSign")
    private String alreadyReturnSign;//已经归还的物品编号


    //添加 GetAndReturn
    @JsonProperty("gname")
    private String gname;
    @JsonProperty("gtel")
    private String gtel;
    @JsonProperty("gwatch")
    private String gwatch;
    @JsonProperty("gmes")
    private String gmes;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date gtime;
    @JsonProperty("rname")
    private String rname;
    @JsonProperty("rtel")
    private String rtel;
    @JsonProperty("rwatch")
    private String rwatch;
    @JsonProperty("rmes")
    private String rmes;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date rtime;
    public void setFlagDTO(Flag flag, String things, GetAndReturn getAndReturn)
    {
        if(flag!=null)
        {
            this.fid=flag.getId();
            this.mes=flag.getMes();
            this.applicant=flag.getApplicant();
            this.college=flag.getCollege();
            this.tel=flag.getTel();
            this.applyTime=flag.getApplytime();
            this.startTime=flag.getStarttime();
            this.endTime=flag.getEndtime();
            this.passTime=flag.getPasstime();
            this.approver=flag.getApprover();
            this.state=flag.getState();
            this.returnTime=flag.getReturntime();
            this.examineState = flag.getExamineState();
            this.activityname = flag.getActivityname();
            this.damageis = flag.getDamageis();
            this.needReturnSigns = flag.getNeedReturnSigns();
            this.allReturnSigns = flag.getAllReturnSigns();
            this.alreadyReturnSign = flag.getAlreadyReturnSign();
        }
        if(things!=null)
        {
            this.things=things;
        }
        if(getAndReturn!=null)
        {
            this.gname=getAndReturn.getGname();
            this.gtel=getAndReturn.getGtel();
            this.gwatch=getAndReturn.getGwatch();
            this.gmes=getAndReturn.getGmes();
            this.gtime=getAndReturn.getGtime();

            this.rname=getAndReturn.getRname();
            this.rtel=getAndReturn.getRtel();
            this.rwatch=getAndReturn.getRwatch();
            this.rmes=getAndReturn.getRmes();
            this.rtime=getAndReturn.getRtime();
        }
    }
    public void setDelayThing(DelayThing delayThing)
    {
        this.delayThing=delayThing;
    }
    public void setDelayThingInfo()
    {
        this.endTime=delayThing.getDelaytime();
        this.state=delayThing.getDelaystate();
    }
}
